import json

import scrapy


class CarrecommendSpider(scrapy.Spider):
    name = "carRecommend"
    allowed_domains = ["guazi.com"]
    start_urls = []
    for i in range(1, 11):
        url = "https://mapi.guazi.com/car-source/carList/pcList?versionId=0.0.0.0&sourceFrom=wap&deviceId=2fd0f752-0dc4-4d32-bdbc-fad705851d4b&osv=Windows+10&minor=&sourceType=&ec_buy_car_list_ab=&location_city=&district_id=&tag=-1&license_date=&auto_type=&driving_type=&gearbox=&road_haul=&air_displacement=&emission=&car_color=&guobie=&bright_spot_config=&seat=&fuel_type=&order=&priceRange=0,-1&tag_types=&diff_city=&intention_options=&initialPriceRange=&monthlyPriceRange=&transfer_num=&car_year=&carid_qigangshu=&carid_jinqixingshi=&cheliangjibie=&page={}&pageSize=20&city_filter=12&city=12&guazi_city=12&qpres=&platfromSource=wap".format(i)
        start_urls.append(url)
    def parse(self, response):
        jstr = json.loads(response.text)
        car_list = jstr['data']['postList']
        for car in car_list:
            title = car['title']
            license_date = car['license_date']


